# encoding: utf-8

from PyQt5.Qt import *
from widget.daoru_page.daoru_page_base import MyDaoruPage
from widget.baseinit_page.init_page_base import MyInitPage
from widget.daoru_task_page.daoru_task_history_page import DaoruTaskPage
from widget.help_page_window import HelpPage


class RootMenu(QWidget):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.resize(200, 800)
        self.setObjectName('my_root_menu')
        self.my_parent = args[0]
        self.setParent(self.my_parent)
        self.setup_menu()
        self.setup_content()

    def setup_menu(self):
        self.label1 = QLabel(self)
        self.label1.setText('数据导入')
        self.label1.move(0, 50)
        self.label1.setProperty('my_label_type', 'root_menu_title')

        self.widget1 = QWidget(self)
        self.widget1.setFixedWidth(190)
        self.widget1.move(10, 100)
        self.widget1.setProperty('my_widget_type', 'root_menu_widget')

        self.label1_btn1 = QPushButton(self.widget1)
        self.label1_btn1.setText('创建任务')
        self.label1_btn1.move(10, 10)
        self.label1_btn1.setProperty('my_label_type', 'root_menu_label')
        self.label1_btn1.setObjectName('daoru_menu_btn')

        self.label1_btn3 = QPushButton(self.widget1)
        self.label1_btn3.setText('执行任务')
        self.label1_btn3.move(10, 60)
        self.label1_btn3.setProperty('my_label_type', 'root_menu_label')
        self.label1_btn3.setObjectName('daoru_task_history_btn')

        self.label1_btn2 = QPushButton(self.widget1)
        self.label1_btn2.setText('基本信息配置')
        self.label1_btn2.move(10, 110)
        self.label1_btn2.setProperty('my_label_type', 'root_menu_label')
        self.label1_btn2.setObjectName('base_init_btn')

        self.label1_btn_help = QPushButton(self)
        self.label1_btn_help.setText('使用文档 >>>')
        # self.label1_btn_help.move(10, 500)
        self.label1_btn_help.setGeometry(10, 750, 150, 50)
        self.label1_btn_help.setProperty('my_label_type', 'help_label')
        self.label1_btn_help.setIcon(QIcon(qApp.cx_project_root.replace('\\', '/') + '/init_file/img/help_hover.png'))
        self.label1_btn_help.setIconSize(QSize(30, 30))
        self.label1_btn_help.clicked.connect(self.show_help_page)

    def setup_content(self):
        # 右侧操作控件,挂载到根窗口
        self.content_widget = QWidget(self.my_parent)
        self.content_widget.move(200, 50)
        self.content_widget.resize(1100, 740)
        self.content_widget.setAttribute(Qt.WA_StyledBackground, True)
        self.content_widget.setObjectName('daoru_widget')
        self.content_widget.close()

        # 挂载导入界面
        self.daoru_widget = MyDaoruPage(self.content_widget)            # 导入界面
        self.init_widget = MyInitPage(self.content_widget)              # 基本信息界面
        self.daoru_task_widget = DaoruTaskPage(self.content_widget)     # 导入任务界面


    def show_help_page(self):
        '''
        显示帮助页面
        :return:
        '''
        self.help_page = HelpPage(width=1150, height=750, my_parent=self)
        self.help_page.show()


